package org.xg.study.servlet;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author CMG
 * @version 1.0
 * @description
 * @cLassName FirstChainFilter
 * @date 2021/9/24 15:49
 **/
public class FirstChainFilter implements Filter {
    public FirstChainFilter() {
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        servletResponse.setContentType("text/html;charset=UTF-8");
        PrintWriter printWriter = servletResponse.getWriter();
        printWriter.write("FirstChainFilter对请求进行处理<br/>");
        filterChain.doFilter(servletRequest, servletResponse);
        printWriter.write("FirstChainFilter对响应进行处理<br/>");
    }

    @Override
    public void destroy() {

    }
}
